using Net35.Xrm.Sdk.Discovery;
using System.Reflection;
namespace Net35.Xrm.Sdk.Client
{
	public static class ServiceConfigurationFactory
	{
		public static IServiceConfiguration<TService> CreateConfiguration<TService>(System.Uri serviceUri)
		{
			return ServiceConfigurationFactory.CreateConfiguration<TService>(serviceUri, false, null);
		}
		public static IServiceConfiguration<TService> CreateConfiguration<TService>(System.Uri serviceUri, bool enableProxyTypes, Assembly assembly)
		{
			if (serviceUri != null)
			{
				if (typeof(TService) == typeof(IDiscoveryService))
				{
					return new DiscoveryServiceConfiguration(serviceUri) as IServiceConfiguration<TService>;
				}
				if (typeof(TService) == typeof(IOrganizationService))
				{
					return new OrganizationServiceConfiguration(serviceUri, enableProxyTypes, assembly) as IServiceConfiguration<TService>;
				}
			}
			return null;
		}
		public static IServiceManagement<TService> CreateManagement<TService>(System.Uri serviceUri)
		{
			return ServiceConfigurationFactory.CreateManagement<TService>(serviceUri, false, null);
		}
		public static IServiceManagement<TService> CreateManagement<TService>(System.Uri serviceUri, bool enableProxyTypes, Assembly assembly)
		{
			if (serviceUri != null)
			{
				if (typeof(TService) == typeof(IDiscoveryService))
				{
					return new DiscoveryServiceConfiguration(serviceUri) as IServiceManagement<TService>;
				}
				if (typeof(TService) == typeof(IOrganizationService))
				{
					return new OrganizationServiceConfiguration(serviceUri, enableProxyTypes, assembly) as IServiceManagement<TService>;
				}
			}
			return null;
		}
	}
}
